<h2>Dashboard</h2>

<% if @inbox.size > 0 %>
  <h3><img src="/images/letter.png" align="left">Inbox</h3>
  <ul>
  <%= render(:partial=>'task/task', :collection=>@inbox, :locals=>{:tasks=>@inbox, :item_name=>'inbox'}) %>
  </ul>
<% end %>

<% if @without_project.size > 0 %>
  <h3><img src="/images/important.png" align="left">Tasks without project</h3>
  <ul>
  <%= render(:partial=>'task/task', :collection=>@without_project, :locals=>{:tasks=>@without_project, :item_name=>'w_pi'}) %>
  </ul>
<% end %>

<% if @invit!=[] %>
<h3><img src="/images/letter.png" align="left">Invitations</h3>

<% for i in @invit %>
<div id="inv<%=i.id%>">
<%=i.name%> invites you to join the project "<%=i.project.name%>"
<%= link_to_remote( "Accept", {:update => "inv"+i.id.to_s, :url =>{ :controller=> :invitation, :action => :accept, :id=>i.id },
 :loading  => visual_effect('appear', 'ind'+i.id.to_s),
 :success => [visual_effect('fade', 'ind'+i.id.to_s), visual_effect('fade','ind'+i.id.to_s), "refresh_project_list();"]},
 {:class=>"btnlnk"}) %>
<%= link_to_remote( "Decline", {:update => "inv"+i.id.to_s, :url =>{ :controller=> :invitation, :action => :decline, :id=>i.id },
 :loading  => visual_effect('appear', 'ind'+i.id.to_s),
 :success => {visual_effect('fade', 'ind'+i.id.to_s), visual_effect('fade','ind'+i.id.to_s)}},
 {:class=>"btnlnk"}) %>

<img id="ind<%=i.id%>" src="/images/loading.gif" style="display:none;">

</div>
<% end %>
<% end %>


<% if @projects.size == 0 and @user.tasks.size == 0-%>
  Welcome.<br/>
  You can now keep track of the tasks you have to do. They will belong to categories called "projects".<br/>
  Each project can have its own group of users.<br/>
  <br/>
  Create a task now by clicking on tasks, in the menu above, or using the quick add menu.<br/>

<% else -%>

<% if @deadlines.size>0 -%>
  <h3><img src="/images/time2.png" align="left">Deadlines</h3>
  <div id="deadlines_content">
  <%= render(:partial=>'task/deadline_tasks', :locals=>{:deadlines=>@deadlines, :tasks=>@tasks}) %>
  </div>
<% end -%>

<% if @calendar.size>0 -%>
  <h3><img src="/images/time2.png" align="left">Calendar</h3>
  <ul>
  <%= render(:partial=>'calendar/event', :collection=>@calendar) %>
  </ul>
<% end -%>

<% if @tasksdone1.size+@tasksdone2.size + @our_tasksdone1.size+@our_tasksdone2.size> 0-%>

  <h3>Tasks done</h3>

  <div class="groupbox">
    <div id="tab_by_other" class="tab selected" onclick="select_tab('by_other','by_me')">by others</div>
    <div id="tab_by_me" class="tab not_selected" onclick="select_tab('by_me','by_other')">by me</div>

    <div id="by_other">
    <% if @tasksdone1.size+@tasksdone2.size > 0-%>
      <ul>
        <% if @tasksdone1.size > 0-%>
        <li>
          <b>Today and yesterday</b>
          <ul style="list-style-type:none;padding:0;font-size:small;">
          <%= render(:partial=>'task', :collection=>@tasksdone1) %>
          </ul>
        </li>
        <br/>
        <% end -%>
        <% if @tasksdone2.size > 0-%>
        <li>
          <b>Last week</b>
          <ul style="list-style-type:none;padding:0;font-size:small;">
          <%= render(:partial=>'task', :collection=>@tasksdone2) %>
          </ul>
        </li>
        <% end -%>
      </ul>
    <% end -%>
    </div>

    <div id="by_me" style="display:none">
    <% if @our_tasksdone1.size+@our_tasksdone2.size > 0-%>
      <ul>
        <% if @our_tasksdone1.size > 0-%>
        <li>
          <b>Today and yesterday</b>
          <ul style="list-style-type:none;padding:0;font-size:small;">
            <%= render(:partial=>'task', :collection=>@our_tasksdone1) %>
          </ul>
        </li>
        <br/>
        <% end -%>
        <% if @our_tasksdone2.size > 0-%>
        <li>
          <b>Last week</b>
          <ul style="list-style-type:none;padding:0;font-size:small;">
            <%= render(:partial=>'task', :collection=>@our_tasksdone2) %>
          </ul>
        </li>
        <% end -%>
      </ul>
    <% end # by me -%>
    </div>
  </div>  

<% end # done tasks -%>

<% if @notes.size > 0 -%>
  <h3>Last notes</h3>
  <ul>
  <%= render(:partial=>'notes/last', :collection=>@notes) %>
  </ul>
<% end -%>


<% end # if one project exists -%>

<h2>Send Feedback</h2>

<% form_remote_tag(:url=>{:action=>'send_feedback'}, :update=>'feedback_results') do %>
Message:<br/>
<%= text_area(:fb, :body, :cols => 60, :rows => 3) %><br/>
<%= submit_tag('Send feedback',:onclick=>'$("feedback_results").update("Sending...")') %>
<div id="feedback_results"></div>
<% end %>

